Create count_pair_with_given_sum.cpp#83
Open
Tusharr0305 wants to merge 1 commit intoignacio-chiazzo:masterfrom
Open
Create count_pair_with_given_sum.cpp#83Tusharr0305 wants to merge 1 commit intoignacio-chiazzo:masterfrom
Tusharr0305 wants to merge 1 commit intoignacio-chiazzo:masterfrom
Conversation
Added Subarray problem
Owner
ignacio-chiazzo
left a comment
There was a problem hiding this comment.
Hey! Thanks for contributing!
This repository is only for solutions in Javascript. We are also following a specific format.
I'd be happy to accept this problem but in Javascript.
Thanks again for contributing.
hot9cups
requested changes
Oct 30, 2022
Collaborator
hot9cups
left a comment
There was a problem hiding this comment.
Additionally to what Ignacio mentioned, I would also request a change in the solution when you do translate to javascript.
You have an O(N^2) solution, but I believe you can achieve an O(N) solution using a Map/Dictionary that stores the frequency of every number in the array, and then traversing the map to get count of pairs.
Author
|
Okay will share 0(N) solution soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added Subarray problem